package com.linzm.jdbc;

import java.io.IOException;
import java.io.InputStream;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Utils {
    /**
     * closeStatement
     *
     * @param statement statement
     * @throws SQLException SQLException
     */
    public static void closeStatement(Statement statement) throws SQLException {
        if (statement != null && !statement.isClosed()) {
            statement.close();
        }
    }

    /**
     * closeResultSet
     *
     * @param resultSet resultSet
     * @throws SQLException SQLException
     */
    public static void closeResultSet(ResultSet resultSet) throws SQLException {
        if (resultSet != null && !resultSet.isClosed()) {
            resultSet.close();
        }
    }

    /**
     * closeInputStream
     *
     * @param inputStream inputStream
     * @throws IOException IOException
     */
    public static void closeInputStream(InputStream inputStream) throws IOException {
        if (inputStream != null) {
            inputStream.close();
        }
    }
}
